home *** CD-ROM | disk | FTP | other *** search
- ;==========================================================================;
- ; 8250 Initialization handler ;
- ; This code also used by the QUADRAM QUADPORT board and 4 async port card;
- ; ;
- ; Copyright 1983 by William E. Westfield. All rights reserved. ;
- ; Copyright 1986, 1987, 1990, 1991 by H. Roy Engehausen. All rights ;
- ; reserved. ;
- ; ;
- ; This software may be freely distributed and used, but it may not ;
- ; under any circumstances be sold by anyone other than the author. ;
- ; It may be distributed by a commercial company as long as it is ;
- ; for no cost. ;
- ; ;
- ;==========================================================================;
-
- CMP chip[SI],chip_8250 ; Is this an 8250?
- JE init_is_8250 ; Yep... Do it
- CMP chip[SI],chip_qrqp ; Is this a QuadRam QuadPort?
- JE init_is_8250 ; Yep... Do it
- CMP chip[SI],chip_4apc ; Is this a 4 async port card?
- JE init_is_8250 ; Yep... Do it
- JMP init_not_8250 ; Nope: skip this
-
- init_is_8250:
-
- MOV CX,baseaddr[SI] ; Get base address for chip
-
- ;--------------------------------------------------------------------------;
- ; Set the FIFO registers in the 16550A ;
- ;--------------------------------------------------------------------------;
-
- IF present_fifo
-
- OR options[SI],opt_fifo ; Turn on FIFO bit
-
- MOV AL,fcr_8250_trig8+fcr_8250_tclr+fcr_8250_rclr+fcr_8250_enabl ;
-
- MOV DX,CX ; Compute port address for the FCR
- ADD DX,fcr_8250 ;
- OUT DX,AL ; Set the FCR
-
- MOV DX,CX ; Compute port address for the IIR
- ADD DX,iir_8250 ;
- IN AL,DX ; Get the IIR
-
- AND AL,iir_8250_fifo ; See if FIFO bits are on
- CMP AL,iir_8250_fifo ;
- JNE init_8250_nofifo ; No FIFO mode here
-
- ;--------------------------------------------------------------------------;
- ; Announce that FIFO was turned on ;
- ;--------------------------------------------------------------------------;
-
- MOV DX,OFFSET msgfifo ; Message
- MOV AH,dos_write_line ; Send to output
- INT dos_vector_no ;
-
- JMP init_8250_fifo ; FIFO mode is OK
-
- msgfifo DB 'FIFO mode enabled',13,10,'$'
-
- ;--------------------------------------------------------------------------;
- ; FIFO not set.. Turn everything off ;
- ;--------------------------------------------------------------------------;
-
- init_8250_nofifo:
-
- SUB AL,AL ; Clear the FCR
-
- MOV DX,CX ; Compute port address for the FCR
- ADD DX,fcr_8250 ;
- OUT DX,AL ; Set the FCR
-
- XOR options[SI],opt_fifo ; Turn off FIFO bit
-
- init_8250_fifo:
-
- ENDIF
-
- ;--------------------------------------------------------------------------;
- ; Set the interrupt registers in the 8250 ;
- ;--------------------------------------------------------------------------;
-
- MOV AL,ier_8250_rda ; Enable data interrupt only
-
- TEST options[SI],opt_trbuf ; Transmit buffering turned on?
- JZ ini_8250_notrbuff ; No - Just want only 1 interrupt
- OR AL,ier_8250_thre+ier_8250_ms ; Yes - We need both modem status enable
- ; and THRE interrupts too
-
- ini_8250_notrbuff:
-
- MOV DX,CX ; Compute port address for the IER
- ADD DX,ier_8250 ;
- OUT DX,AL ; Set the IER
-
- ;--------------------------------------------------------------------------;
- ; Signal goodness to the outboard equipment ;
- ;--------------------------------------------------------------------------;
-
- MOV DX,CX ; Compute port address for the MCR
- ADD DX,mcr_8250 ;
- MOV AL,hon_8250 ; Raise DTR, RTS, and OUT2. OUT2 turns
- ; on interrupts
- OUT DX,AL ;
-
- ;--------------------------------------------------------------------------;
- ; Collect any pending interrupts to ensure okie dokie ;
- ;--------------------------------------------------------------------------;
-
- MOV AH,07FH ; Maximum looping
-
- ini_8250_cleani:
-
- MOV DX,CX ; Compute port address for the input buffer
- ADD DX,rbr_8250 ;
- IN AL,DX ; Read the input buffer and throw it away
-
- MOV DX,CX ; Compute port address for the LSR
- ADD DX,lsr_8250 ;
- IN AL,DX ; Read the LSR and throw it away
-
- MOV DX,CX ; Compute port address for the MSR
- ADD DX,msr_8250 ;
- IN AL,DX ; Read the MSR and throw it away
-
- MOV DX,CX ; Compute port address for the IIR
- ADD DX,iir_8250 ;
- IN AL,DX ; Read the IIR
-
- AND AL,iir_8250_ip ; If no interrupt pending, fall out
- JNZ ini_8250_cleanid ; No interrupt pending
- DEC AH ; Decrement loop counter
- JNZ ini_8250_cleani ; Try cleaning out one more time
-
- ini_8250_cleanid:
-
- ;--------------------------------------------------------------------------;
- ; Done ;
- ;--------------------------------------------------------------------------;
-
- init_not_8250: ; Not 8250 come here!